{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 71,
   "id": "fde79ed1",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "87442\n"
     ]
    }
   ],
   "source": [
    "# T1\n",
    "import csv\n",
    "data=[]\n",
    "j=0\n",
    "\n",
    "with open('gaze.csv','r') as csvfile:\n",
    "    csv_reader = csv.reader(csvfile)   # 使用csv.reader方法读取csvfile中的文件\n",
    "    for row in csv_reader:            \n",
    "        data.append(row[2])            # 选择confidence列加入到data数组中    \n",
    "    del(data[0])                       # 将confidence列的标题删除，否则下面转换类型时报错。\n",
    "    \n",
    "for i in data:\n",
    "    if float(i)>= 0.9:\n",
    "        j += 1\n",
    "        \n",
    "print(j)       \n",
    "\n",
    "# # 用pandas库 \n",
    "# import pandas as pd\n",
    "# df = pd.read_csv('gaze.csv')\n",
    "# df = df[df['confidence']>=0.9]        # 选取出confidence > 0.9的行,print((df))即可输出满足的所有数据。\n",
    "\n",
    "# print(len(df))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 105,
   "id": "92da1932",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "120036\n"
     ]
    }
   ],
   "source": [
    "# T2\n",
    "import csv\n",
    "x_data = []\n",
    "y_data = []\n",
    "with open('gaze.csv','r') as csvfile:\n",
    "    csv_reader = csv.reader(csvfile)       # 使用csv.reader方法读取csvfile中的文件\n",
    "    for row in csv_reader:            \n",
    "        x_data.append(row[3])              # 选择confidence列加入到data数组中    \n",
    "        y_data.append(row[4])     \n",
    "    del(x_data[0])                         # 将confidence列的标题删除，否则下面转换类型时报错。\n",
    "    del(y_data[0])\n",
    "\n",
    "float_x = list(map(float, x_data))         # 将data数组内元素都转换为浮点数 \n",
    "float_y = list(map(float, y_data))\n",
    "x_mean = (sum(float_x)) / (len(float_x))\n",
    "y_mean = (sum(float_y)) / (len(float_y))\n",
    "\n",
    "x_offset_sum=0\n",
    "y_offset_sum=0\n",
    "i = 0\n",
    "while i < len(float_x):\n",
    "    x_offset_sum += (float_x[i] - x_mean)**2\n",
    "    y_offset_sum += (float_y[i] - y_mean)**2\n",
    "    i += 1\n",
    "\n",
    "x_sqrt =  (x_offset_sum / len(float_x))** (1/2)\n",
    "y_sqrt =  (y_offset_sum / len(float_y))** (1/2)\n",
    "j = 0\n",
    "k = 0\n",
    "while j < len(float_x) :\n",
    "    if x_mean + 3*x_sqrt >= float_x[j]>= x_mean - 3*x_sqrt \\\n",
    "    and y_mean + 3*y_sqrt >= float_y[j]>= y_mean - 3*y_sqrt:\n",
    "        k += 1\n",
    "    j += 1\n",
    "        \n",
    "print(k)        \n",
    "\n",
    "# # 用pandas库\n",
    "# import pandas as pd\n",
    "# df = pd.read_csv('gaze.csv')\n",
    "\n",
    "# x_mean=(df[\"norm_pos_x\"].mean())\n",
    "# x_std=(df[\"norm_pos_x\"].std())\n",
    "# y_mean=(df[\"norm_pos_y\"].mean())\n",
    "# y_std=(df[\"norm_pos_y\"].std())\n",
    "# print(x_mean)\n",
    "# print(y_mean)\n",
    "# print(x_std)\n",
    "# print(y_std)\n",
    "\n",
    "# df = df[df[\"norm_pos_x\"] <= x_mean + 3 * x_std]\n",
    "# df = df[df[\"norm_pos_x\"] >= x_mean - 3 * x_std]\n",
    "# df = df[df[\"norm_pos_y\"] <= y_mean + 3 * y_std]\n",
    "# df = df[df[\"norm_pos_y\"] >= y_mean - 3 * y_std]\n",
    "\n",
    "# print(len(df))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 91,
   "id": "7071f0d1",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['1970-01-01T00:29:10.776780+0000']\n",
      "['1970-01-01T00:29:10.776787+0000']\n",
      "['1970-01-01T00:29:10.779709+0000']\n",
      "['1970-01-01T00:29:10.779759+0000']\n",
      "['1970-01-01T00:29:10.787485+0000']\n",
      "['1970-01-01T00:29:10.787579+0000']\n",
      "['1970-01-01T00:29:10.789480+0000']\n",
      "['1970-01-01T00:29:10.793583+0000']\n",
      "['1970-01-01T00:29:10.795682+0000']\n",
      "['1970-01-01T00:29:10.798406+0000']\n",
      "······ \n",
      "······\n",
      "此处省略 125244 条数据\n",
      "······\n",
      "······\n",
      "['1970-01-01T00:34:03.683578+0000']\n",
      "['1970-01-01T00:34:03.688172+0000']\n",
      "['1970-01-01T00:34:03.690149+0000']\n",
      "['1970-01-01T00:34:03.692745+0000']\n",
      "['1970-01-01T00:34:03.694169+0000']\n",
      "['1970-01-01T00:34:03.695600+0000']\n",
      "['1970-01-01T00:34:03.697570+0000']\n",
      "['1970-01-01T00:34:03.701580+0000']\n",
      "['1970-01-01T00:34:03.703608+0000']\n",
      "['1970-01-01T00:34:03.705573+0000']\n"
     ]
    }
   ],
   "source": [
    "# T3\n",
    "import csv\n",
    "import numpy\n",
    "#import numpy\n",
    "i = 1\n",
    "data = []\n",
    "with open('gaze.csv','r') as csvfile:\n",
    "    csv_reader = csv.reader(csvfile)  \n",
    "    for row in csv_reader:            \n",
    "        data.append(row[0])           # 选择时间戳一列加入到data数组中\n",
    "        \n",
    "        \n",
    "while i < len(data):\n",
    "    decimal_part = int(data[i].split(\".\")[1][:6:].ljust(6, '0')) # split(\".\")[1][:6:]取小数部分后六位，ljust方法将不足六位的用零补齐。\n",
    "    integer_part = data[i].split(\".\")[0]\n",
    "    second_num = int(integer_part)\n",
    "    m, s = divmod(second_num, 60)\n",
    "    h_row, m = divmod(m, 60)\n",
    "    h = h_row % 24\n",
    "    d = h_row // 24\n",
    "    new_time=(\"1970-01-%02dT%02d:%02d:%02d.%d+0000\" % (d ,h ,m ,s ,decimal_part))\n",
    "    data[i]=[new_time]\n",
    "    i += 1\n",
    "\n",
    "del data[0]\n",
    "for v in data[:10]:\n",
    "    print(v)\n",
    "    \n",
    "print(\"\"\"······ \n",
    "······\n",
    "此处省略\"\"\",len(data) - 20,\"\"\"条数据\n",
    "······\n",
    "······\"\"\")\n",
    "\n",
    "for v in data[-10:]:\n",
    "    print(v)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "id": "abffe51b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "采样率为: 427.62\n"
     ]
    }
   ],
   "source": [
    "# T4 \n",
    "import csv\n",
    "data = []\n",
    "time_list = []\n",
    "frequency_list = []\n",
    "i = 0\n",
    "\n",
    "with open('gaze.csv','r') as csvfile:\n",
    "    csv_reader = csv.reader(csvfile)  \n",
    "    for row in csv_reader:            \n",
    "        data.append(row[0])                                 # 选择gaze_timestamp列加入到data数组中    \n",
    "    del(data[0])                      \n",
    "    \n",
    "while i < len(data):\n",
    "    data[i] = int(float(data[i]))\n",
    "    i += 1\n",
    "\n",
    "time_list = set(data)                                       # time_list中存放不重复的时间\n",
    "\n",
    "for j in time_list:\n",
    "    frequency_list.append(data.count(j))                    # frequency_list中存放每秒采集的数据数\n",
    "\n",
    "fre_mean = (sum(frequency_list)) / (len(frequency_list))\n",
    "j = 0\n",
    "fre_offsetSum = 0\n",
    "while j < len(frequency_list):\n",
    "    fre_offsetSum += (frequency_list[j] - fre_mean)**2\n",
    "    j += 1\n",
    "fre_sqrt =  (fre_offsetSum/ len(frequency_list))** (1/2)\n",
    "\n",
    "def is_normal(n):\n",
    "    return fre_mean + 3*fre_sqrt >= n >= fre_mean - 3*fre_sqrt\n",
    "    \n",
    "target_list = list(filter(is_normal, frequency_list))       # 过滤掉异常数据\n",
    "sampling_rate = (sum(target_list)) / (len(target_list))     # 将过滤后的平均值作为采样率\n",
    "\n",
    "print(\"采样率为:\",round(sampling_rate,2))                   # 采样率保留一定的位数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 147,
   "id": "4a7dff53",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>world_index</th>\n",
       "      <th>confidence</th>\n",
       "      <th>norm_pos_x</th>\n",
       "      <th>norm_pos_y</th>\n",
       "      <th>gaze_point_3d_x</th>\n",
       "      <th>gaze_point_3d_y</th>\n",
       "      <th>gaze_point_3d_z</th>\n",
       "      <th>eye_center0_3d_x</th>\n",
       "      <th>eye_center0_3d_y</th>\n",
       "      <th>eye_center0_3d_z</th>\n",
       "      <th>gaze_normal0_x</th>\n",
       "      <th>gaze_normal0_y</th>\n",
       "      <th>gaze_normal0_z</th>\n",
       "      <th>eye_center1_3d_x</th>\n",
       "      <th>eye_center1_3d_y</th>\n",
       "      <th>eye_center1_3d_z</th>\n",
       "      <th>gaze_normal1_x</th>\n",
       "      <th>gaze_normal1_y</th>\n",
       "      <th>gaze_normal1_z</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>gaze_timestamp</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1970-01-01 00:01:28.150000+00:00</th>\n",
       "      <td>139.590619</td>\n",
       "      <td>0.710526</td>\n",
       "      <td>0.439230</td>\n",
       "      <td>0.477953</td>\n",
       "      <td>1057.200767</td>\n",
       "      <td>-452.357218</td>\n",
       "      <td>-7705.641117</td>\n",
       "      <td>14.452774</td>\n",
       "      <td>14.927761</td>\n",
       "      <td>-20.027057</td>\n",
       "      <td>-0.127847</td>\n",
       "      <td>0.067605</td>\n",
       "      <td>0.889367</td>\n",
       "      <td>-39.709336</td>\n",
       "      <td>14.549297</td>\n",
       "      <td>-19.780972</td>\n",
       "      <td>-0.148169</td>\n",
       "      <td>0.097099</td>\n",
       "      <td>0.982526</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1970-01-01 00:01:28.160000+00:00</th>\n",
       "      <td>427.327388</td>\n",
       "      <td>0.823882</td>\n",
       "      <td>0.315246</td>\n",
       "      <td>0.422748</td>\n",
       "      <td>3337.368667</td>\n",
       "      <td>-1701.716549</td>\n",
       "      <td>-22726.698137</td>\n",
       "      <td>18.376092</td>\n",
       "      <td>14.900405</td>\n",
       "      <td>-20.301762</td>\n",
       "      <td>-0.244505</td>\n",
       "      <td>0.090579</td>\n",
       "      <td>0.951078</td>\n",
       "      <td>-35.448202</td>\n",
       "      <td>14.565285</td>\n",
       "      <td>-25.917069</td>\n",
       "      <td>-0.144661</td>\n",
       "      <td>-0.042391</td>\n",
       "      <td>0.978452</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1970-01-01 00:01:28.170000+00:00</th>\n",
       "      <td>727.262406</td>\n",
       "      <td>0.818867</td>\n",
       "      <td>0.463320</td>\n",
       "      <td>0.387076</td>\n",
       "      <td>-1242.344319</td>\n",
       "      <td>642.260330</td>\n",
       "      <td>8615.747968</td>\n",
       "      <td>17.769681</td>\n",
       "      <td>14.903067</td>\n",
       "      <td>-20.325156</td>\n",
       "      <td>-0.022525</td>\n",
       "      <td>0.007327</td>\n",
       "      <td>0.966231</td>\n",
       "      <td>-35.357652</td>\n",
       "      <td>14.696238</td>\n",
       "      <td>-26.142450</td>\n",
       "      <td>-0.126900</td>\n",
       "      <td>0.244343</td>\n",
       "      <td>0.946971</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1970-01-01 00:01:28.180000+00:00</th>\n",
       "      <td>1027.420300</td>\n",
       "      <td>0.891241</td>\n",
       "      <td>0.396745</td>\n",
       "      <td>0.424165</td>\n",
       "      <td>-2108.479843</td>\n",
       "      <td>906.247607</td>\n",
       "      <td>14102.763104</td>\n",
       "      <td>19.211247</td>\n",
       "      <td>14.909636</td>\n",
       "      <td>-20.153195</td>\n",
       "      <td>-0.166638</td>\n",
       "      <td>-0.027207</td>\n",
       "      <td>0.973686</td>\n",
       "      <td>-37.086310</td>\n",
       "      <td>14.788350</td>\n",
       "      <td>-23.480002</td>\n",
       "      <td>-0.052744</td>\n",
       "      <td>0.080061</td>\n",
       "      <td>0.991507</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1970-01-01 00:01:28.190000+00:00</th>\n",
       "      <td>1326.979118</td>\n",
       "      <td>0.785471</td>\n",
       "      <td>0.379900</td>\n",
       "      <td>0.380401</td>\n",
       "      <td>-768.089154</td>\n",
       "      <td>360.364234</td>\n",
       "      <td>5323.206488</td>\n",
       "      <td>16.025616</td>\n",
       "      <td>14.690458</td>\n",
       "      <td>-20.652484</td>\n",
       "      <td>-0.118421</td>\n",
       "      <td>0.126559</td>\n",
       "      <td>0.969294</td>\n",
       "      <td>-36.983088</td>\n",
       "      <td>14.811906</td>\n",
       "      <td>-23.625989</td>\n",
       "      <td>-0.220017</td>\n",
       "      <td>0.090418</td>\n",
       "      <td>0.967101</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1970-01-01 00:01:28.200000+00:00</th>\n",
       "      <td>1627.273259</td>\n",
       "      <td>0.814194</td>\n",
       "      <td>0.380568</td>\n",
       "      <td>0.427541</td>\n",
       "      <td>-374.635967</td>\n",
       "      <td>67.621475</td>\n",
       "      <td>1697.460916</td>\n",
       "      <td>17.905347</td>\n",
       "      <td>14.398223</td>\n",
       "      <td>-20.954195</td>\n",
       "      <td>-0.157902</td>\n",
       "      <td>0.074265</td>\n",
       "      <td>0.957535</td>\n",
       "      <td>-36.891102</td>\n",
       "      <td>14.793806</td>\n",
       "      <td>-23.749654</td>\n",
       "      <td>-0.151808</td>\n",
       "      <td>0.053767</td>\n",
       "      <td>0.984200</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1970-01-01 00:01:28.210000+00:00</th>\n",
       "      <td>1927.376724</td>\n",
       "      <td>0.913206</td>\n",
       "      <td>0.394634</td>\n",
       "      <td>0.432810</td>\n",
       "      <td>-25.523896</td>\n",
       "      <td>-42.417587</td>\n",
       "      <td>-235.858448</td>\n",
       "      <td>18.374399</td>\n",
       "      <td>14.384531</td>\n",
       "      <td>-20.933248</td>\n",
       "      <td>-0.146237</td>\n",
       "      <td>0.051453</td>\n",
       "      <td>0.963780</td>\n",
       "      <td>-37.100070</td>\n",
       "      <td>14.775316</td>\n",
       "      <td>-23.444882</td>\n",
       "      <td>-0.124904</td>\n",
       "      <td>0.055827</td>\n",
       "      <td>0.987059</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1970-01-01 00:01:28.220000+00:00</th>\n",
       "      <td>2227.304185</td>\n",
       "      <td>0.924815</td>\n",
       "      <td>0.417549</td>\n",
       "      <td>0.417772</td>\n",
       "      <td>-50.595705</td>\n",
       "      <td>6.410614</td>\n",
       "      <td>172.322187</td>\n",
       "      <td>19.053186</td>\n",
       "      <td>14.379750</td>\n",
       "      <td>-20.902658</td>\n",
       "      <td>-0.084801</td>\n",
       "      <td>0.065100</td>\n",
       "      <td>0.975999</td>\n",
       "      <td>-37.135465</td>\n",
       "      <td>14.774882</td>\n",
       "      <td>-23.415255</td>\n",
       "      <td>-0.157212</td>\n",
       "      <td>0.108161</td>\n",
       "      <td>0.975239</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1970-01-01 00:01:28.230000+00:00</th>\n",
       "      <td>2527.261632</td>\n",
       "      <td>0.861221</td>\n",
       "      <td>0.393230</td>\n",
       "      <td>0.450729</td>\n",
       "      <td>-48.748418</td>\n",
       "      <td>241.475250</td>\n",
       "      <td>15.568423</td>\n",
       "      <td>17.316647</td>\n",
       "      <td>14.433381</td>\n",
       "      <td>-20.905859</td>\n",
       "      <td>-0.166249</td>\n",
       "      <td>0.057002</td>\n",
       "      <td>0.930546</td>\n",
       "      <td>-37.274171</td>\n",
       "      <td>14.768857</td>\n",
       "      <td>-23.238987</td>\n",
       "      <td>-0.116777</td>\n",
       "      <td>0.027554</td>\n",
       "      <td>0.987826</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1970-01-01 00:01:28.240000+00:00</th>\n",
       "      <td>2827.209210</td>\n",
       "      <td>0.905355</td>\n",
       "      <td>0.401741</td>\n",
       "      <td>0.446221</td>\n",
       "      <td>-89.063626</td>\n",
       "      <td>48.632932</td>\n",
       "      <td>820.914005</td>\n",
       "      <td>18.474805</td>\n",
       "      <td>14.483989</td>\n",
       "      <td>-20.756235</td>\n",
       "      <td>-0.144264</td>\n",
       "      <td>0.043767</td>\n",
       "      <td>0.950410</td>\n",
       "      <td>-37.760146</td>\n",
       "      <td>14.754257</td>\n",
       "      <td>-22.535525</td>\n",
       "      <td>-0.110134</td>\n",
       "      <td>0.055378</td>\n",
       "      <td>0.986496</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1970-01-01 00:01:28.250000+00:00</th>\n",
       "      <td>3127.156899</td>\n",
       "      <td>0.883552</td>\n",
       "      <td>0.438003</td>\n",
       "      <td>0.422756</td>\n",
       "      <td>-22.722898</td>\n",
       "      <td>18.080452</td>\n",
       "      <td>228.662741</td>\n",
       "      <td>17.713527</td>\n",
       "      <td>14.500347</td>\n",
       "      <td>-20.779722</td>\n",
       "      <td>-0.099678</td>\n",
       "      <td>0.045776</td>\n",
       "      <td>0.949888</td>\n",
       "      <td>-37.704338</td>\n",
       "      <td>14.754874</td>\n",
       "      <td>-22.626959</td>\n",
       "      <td>-0.120907</td>\n",
       "      <td>0.106926</td>\n",
       "      <td>0.979176</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1970-01-01 00:01:28.260000+00:00</th>\n",
       "      <td>3427.388525</td>\n",
       "      <td>0.837652</td>\n",
       "      <td>0.424930</td>\n",
       "      <td>0.435930</td>\n",
       "      <td>-567.859086</td>\n",
       "      <td>306.974687</td>\n",
       "      <td>4021.785692</td>\n",
       "      <td>16.873866</td>\n",
       "      <td>14.520387</td>\n",
       "      <td>-20.820135</td>\n",
       "      <td>-0.145078</td>\n",
       "      <td>0.057476</td>\n",
       "      <td>0.925963</td>\n",
       "      <td>-37.279303</td>\n",
       "      <td>14.776168</td>\n",
       "      <td>-23.354749</td>\n",
       "      <td>-0.107375</td>\n",
       "      <td>0.052359</td>\n",
       "      <td>0.990495</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1970-01-01 00:01:28.270000+00:00</th>\n",
       "      <td>3727.249825</td>\n",
       "      <td>0.922919</td>\n",
       "      <td>0.397060</td>\n",
       "      <td>0.438005</td>\n",
       "      <td>-162.368800</td>\n",
       "      <td>65.515843</td>\n",
       "      <td>965.130946</td>\n",
       "      <td>18.457917</td>\n",
       "      <td>14.504044</td>\n",
       "      <td>-20.787465</td>\n",
       "      <td>-0.146731</td>\n",
       "      <td>0.050133</td>\n",
       "      <td>0.954728</td>\n",
       "      <td>-37.168200</td>\n",
       "      <td>14.782509</td>\n",
       "      <td>-23.543019</td>\n",
       "      <td>-0.108207</td>\n",
       "      <td>0.048913</td>\n",
       "      <td>0.986929</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1970-01-01 00:01:28.280000+00:00</th>\n",
       "      <td>4027.248363</td>\n",
       "      <td>0.924187</td>\n",
       "      <td>0.394686</td>\n",
       "      <td>0.424216</td>\n",
       "      <td>-1142.464295</td>\n",
       "      <td>485.814929</td>\n",
       "      <td>6895.807307</td>\n",
       "      <td>18.617055</td>\n",
       "      <td>14.503239</td>\n",
       "      <td>-20.779560</td>\n",
       "      <td>-0.150297</td>\n",
       "      <td>0.058772</td>\n",
       "      <td>0.955741</td>\n",
       "      <td>-37.168377</td>\n",
       "      <td>14.779644</td>\n",
       "      <td>-23.535104</td>\n",
       "      <td>-0.118526</td>\n",
       "      <td>0.056326</td>\n",
       "      <td>0.988779</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1970-01-01 00:01:28.290000+00:00</th>\n",
       "      <td>4327.169705</td>\n",
       "      <td>0.862455</td>\n",
       "      <td>0.427455</td>\n",
       "      <td>0.453087</td>\n",
       "      <td>-872.740001</td>\n",
       "      <td>357.027980</td>\n",
       "      <td>5099.627736</td>\n",
       "      <td>17.337049</td>\n",
       "      <td>14.509463</td>\n",
       "      <td>-20.842460</td>\n",
       "      <td>-0.093084</td>\n",
       "      <td>0.052902</td>\n",
       "      <td>0.943567</td>\n",
       "      <td>-37.168463</td>\n",
       "      <td>14.778240</td>\n",
       "      <td>-23.531224</td>\n",
       "      <td>-0.142864</td>\n",
       "      <td>0.105255</td>\n",
       "      <td>0.981360</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1970-01-01 00:01:28.300000+00:00</th>\n",
       "      <td>4627.220873</td>\n",
       "      <td>0.944679</td>\n",
       "      <td>0.411236</td>\n",
       "      <td>0.430831</td>\n",
       "      <td>1879.454417</td>\n",
       "      <td>-992.978787</td>\n",
       "      <td>-14821.463638</td>\n",
       "      <td>19.205400</td>\n",
       "      <td>14.500250</td>\n",
       "      <td>-20.750294</td>\n",
       "      <td>-0.128417</td>\n",
       "      <td>0.013018</td>\n",
       "      <td>0.980309</td>\n",
       "      <td>-37.168463</td>\n",
       "      <td>14.778240</td>\n",
       "      <td>-23.531224</td>\n",
       "      <td>-0.090173</td>\n",
       "      <td>0.077162</td>\n",
       "      <td>0.990872</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1970-01-01 00:01:28.310000+00:00</th>\n",
       "      <td>4927.314106</td>\n",
       "      <td>0.911966</td>\n",
       "      <td>0.407537</td>\n",
       "      <td>0.458938</td>\n",
       "      <td>4.926919</td>\n",
       "      <td>15.475906</td>\n",
       "      <td>158.618249</td>\n",
       "      <td>18.099087</td>\n",
       "      <td>14.505705</td>\n",
       "      <td>-20.804868</td>\n",
       "      <td>-0.135633</td>\n",
       "      <td>0.043154</td>\n",
       "      <td>0.945174</td>\n",
       "      <td>-37.168463</td>\n",
       "      <td>14.778240</td>\n",
       "      <td>-23.531224</td>\n",
       "      <td>-0.120012</td>\n",
       "      <td>0.060891</td>\n",
       "      <td>0.987876</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1970-01-01 00:01:28.320000+00:00</th>\n",
       "      <td>5227.233590</td>\n",
       "      <td>0.885634</td>\n",
       "      <td>0.420252</td>\n",
       "      <td>0.434842</td>\n",
       "      <td>-96.477818</td>\n",
       "      <td>67.200756</td>\n",
       "      <td>710.727354</td>\n",
       "      <td>17.605449</td>\n",
       "      <td>14.508140</td>\n",
       "      <td>-20.829220</td>\n",
       "      <td>-0.134965</td>\n",
       "      <td>0.041200</td>\n",
       "      <td>0.949101</td>\n",
       "      <td>-37.168463</td>\n",
       "      <td>14.778240</td>\n",
       "      <td>-23.531224</td>\n",
       "      <td>-0.112555</td>\n",
       "      <td>0.075101</td>\n",
       "      <td>0.990206</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1970-01-01 00:01:28.330000+00:00</th>\n",
       "      <td>5527.237973</td>\n",
       "      <td>0.904911</td>\n",
       "      <td>0.410326</td>\n",
       "      <td>0.477685</td>\n",
       "      <td>-153.315682</td>\n",
       "      <td>64.262367</td>\n",
       "      <td>1066.041403</td>\n",
       "      <td>17.632638</td>\n",
       "      <td>14.508006</td>\n",
       "      <td>-20.827878</td>\n",
       "      <td>-0.145121</td>\n",
       "      <td>0.033099</td>\n",
       "      <td>0.923413</td>\n",
       "      <td>-37.168463</td>\n",
       "      <td>14.778240</td>\n",
       "      <td>-23.531224</td>\n",
       "      <td>-0.101355</td>\n",
       "      <td>0.053868</td>\n",
       "      <td>0.990909</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1970-01-01 00:01:28.340000+00:00</th>\n",
       "      <td>5827.196449</td>\n",
       "      <td>0.906714</td>\n",
       "      <td>0.405692</td>\n",
       "      <td>0.475158</td>\n",
       "      <td>-60.501627</td>\n",
       "      <td>-43.480292</td>\n",
       "      <td>-586.324610</td>\n",
       "      <td>17.436216</td>\n",
       "      <td>14.508988</td>\n",
       "      <td>-20.842538</td>\n",
       "      <td>-0.147904</td>\n",
       "      <td>-0.011806</td>\n",
       "      <td>0.928220</td>\n",
       "      <td>-37.081902</td>\n",
       "      <td>14.778114</td>\n",
       "      <td>-23.633386</td>\n",
       "      <td>-0.056927</td>\n",
       "      <td>0.074000</td>\n",
       "      <td>0.990144</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                  world_index  confidence  norm_pos_x  \\\n",
       "gaze_timestamp                                                          \n",
       "1970-01-01 00:01:28.150000+00:00   139.590619    0.710526    0.439230   \n",
       "1970-01-01 00:01:28.160000+00:00   427.327388    0.823882    0.315246   \n",
       "1970-01-01 00:01:28.170000+00:00   727.262406    0.818867    0.463320   \n",
       "1970-01-01 00:01:28.180000+00:00  1027.420300    0.891241    0.396745   \n",
       "1970-01-01 00:01:28.190000+00:00  1326.979118    0.785471    0.379900   \n",
       "1970-01-01 00:01:28.200000+00:00  1627.273259    0.814194    0.380568   \n",
       "1970-01-01 00:01:28.210000+00:00  1927.376724    0.913206    0.394634   \n",
       "1970-01-01 00:01:28.220000+00:00  2227.304185    0.924815    0.417549   \n",
       "1970-01-01 00:01:28.230000+00:00  2527.261632    0.861221    0.393230   \n",
       "1970-01-01 00:01:28.240000+00:00  2827.209210    0.905355    0.401741   \n",
       "1970-01-01 00:01:28.250000+00:00  3127.156899    0.883552    0.438003   \n",
       "1970-01-01 00:01:28.260000+00:00  3427.388525    0.837652    0.424930   \n",
       "1970-01-01 00:01:28.270000+00:00  3727.249825    0.922919    0.397060   \n",
       "1970-01-01 00:01:28.280000+00:00  4027.248363    0.924187    0.394686   \n",
       "1970-01-01 00:01:28.290000+00:00  4327.169705    0.862455    0.427455   \n",
       "1970-01-01 00:01:28.300000+00:00  4627.220873    0.944679    0.411236   \n",
       "1970-01-01 00:01:28.310000+00:00  4927.314106    0.911966    0.407537   \n",
       "1970-01-01 00:01:28.320000+00:00  5227.233590    0.885634    0.420252   \n",
       "1970-01-01 00:01:28.330000+00:00  5527.237973    0.904911    0.410326   \n",
       "1970-01-01 00:01:28.340000+00:00  5827.196449    0.906714    0.405692   \n",
       "\n",
       "                                  norm_pos_y  gaze_point_3d_x  \\\n",
       "gaze_timestamp                                                  \n",
       "1970-01-01 00:01:28.150000+00:00    0.477953      1057.200767   \n",
       "1970-01-01 00:01:28.160000+00:00    0.422748      3337.368667   \n",
       "1970-01-01 00:01:28.170000+00:00    0.387076     -1242.344319   \n",
       "1970-01-01 00:01:28.180000+00:00    0.424165     -2108.479843   \n",
       "1970-01-01 00:01:28.190000+00:00    0.380401      -768.089154   \n",
       "1970-01-01 00:01:28.200000+00:00    0.427541      -374.635967   \n",
       "1970-01-01 00:01:28.210000+00:00    0.432810       -25.523896   \n",
       "1970-01-01 00:01:28.220000+00:00    0.417772       -50.595705   \n",
       "1970-01-01 00:01:28.230000+00:00    0.450729       -48.748418   \n",
       "1970-01-01 00:01:28.240000+00:00    0.446221       -89.063626   \n",
       "1970-01-01 00:01:28.250000+00:00    0.422756       -22.722898   \n",
       "1970-01-01 00:01:28.260000+00:00    0.435930      -567.859086   \n",
       "1970-01-01 00:01:28.270000+00:00    0.438005      -162.368800   \n",
       "1970-01-01 00:01:28.280000+00:00    0.424216     -1142.464295   \n",
       "1970-01-01 00:01:28.290000+00:00    0.453087      -872.740001   \n",
       "1970-01-01 00:01:28.300000+00:00    0.430831      1879.454417   \n",
       "1970-01-01 00:01:28.310000+00:00    0.458938         4.926919   \n",
       "1970-01-01 00:01:28.320000+00:00    0.434842       -96.477818   \n",
       "1970-01-01 00:01:28.330000+00:00    0.477685      -153.315682   \n",
       "1970-01-01 00:01:28.340000+00:00    0.475158       -60.501627   \n",
       "\n",
       "                                  gaze_point_3d_y  gaze_point_3d_z  \\\n",
       "gaze_timestamp                                                       \n",
       "1970-01-01 00:01:28.150000+00:00      -452.357218     -7705.641117   \n",
       "1970-01-01 00:01:28.160000+00:00     -1701.716549    -22726.698137   \n",
       "1970-01-01 00:01:28.170000+00:00       642.260330      8615.747968   \n",
       "1970-01-01 00:01:28.180000+00:00       906.247607     14102.763104   \n",
       "1970-01-01 00:01:28.190000+00:00       360.364234      5323.206488   \n",
       "1970-01-01 00:01:28.200000+00:00        67.621475      1697.460916   \n",
       "1970-01-01 00:01:28.210000+00:00       -42.417587      -235.858448   \n",
       "1970-01-01 00:01:28.220000+00:00         6.410614       172.322187   \n",
       "1970-01-01 00:01:28.230000+00:00       241.475250        15.568423   \n",
       "1970-01-01 00:01:28.240000+00:00        48.632932       820.914005   \n",
       "1970-01-01 00:01:28.250000+00:00        18.080452       228.662741   \n",
       "1970-01-01 00:01:28.260000+00:00       306.974687      4021.785692   \n",
       "1970-01-01 00:01:28.270000+00:00        65.515843       965.130946   \n",
       "1970-01-01 00:01:28.280000+00:00       485.814929      6895.807307   \n",
       "1970-01-01 00:01:28.290000+00:00       357.027980      5099.627736   \n",
       "1970-01-01 00:01:28.300000+00:00      -992.978787    -14821.463638   \n",
       "1970-01-01 00:01:28.310000+00:00        15.475906       158.618249   \n",
       "1970-01-01 00:01:28.320000+00:00        67.200756       710.727354   \n",
       "1970-01-01 00:01:28.330000+00:00        64.262367      1066.041403   \n",
       "1970-01-01 00:01:28.340000+00:00       -43.480292      -586.324610   \n",
       "\n",
       "                                  eye_center0_3d_x  eye_center0_3d_y  \\\n",
       "gaze_timestamp                                                         \n",
       "1970-01-01 00:01:28.150000+00:00         14.452774         14.927761   \n",
       "1970-01-01 00:01:28.160000+00:00         18.376092         14.900405   \n",
       "1970-01-01 00:01:28.170000+00:00         17.769681         14.903067   \n",
       "1970-01-01 00:01:28.180000+00:00         19.211247         14.909636   \n",
       "1970-01-01 00:01:28.190000+00:00         16.025616         14.690458   \n",
       "1970-01-01 00:01:28.200000+00:00         17.905347         14.398223   \n",
       "1970-01-01 00:01:28.210000+00:00         18.374399         14.384531   \n",
       "1970-01-01 00:01:28.220000+00:00         19.053186         14.379750   \n",
       "1970-01-01 00:01:28.230000+00:00         17.316647         14.433381   \n",
       "1970-01-01 00:01:28.240000+00:00         18.474805         14.483989   \n",
       "1970-01-01 00:01:28.250000+00:00         17.713527         14.500347   \n",
       "1970-01-01 00:01:28.260000+00:00         16.873866         14.520387   \n",
       "1970-01-01 00:01:28.270000+00:00         18.457917         14.504044   \n",
       "1970-01-01 00:01:28.280000+00:00         18.617055         14.503239   \n",
       "1970-01-01 00:01:28.290000+00:00         17.337049         14.509463   \n",
       "1970-01-01 00:01:28.300000+00:00         19.205400         14.500250   \n",
       "1970-01-01 00:01:28.310000+00:00         18.099087         14.505705   \n",
       "1970-01-01 00:01:28.320000+00:00         17.605449         14.508140   \n",
       "1970-01-01 00:01:28.330000+00:00         17.632638         14.508006   \n",
       "1970-01-01 00:01:28.340000+00:00         17.436216         14.508988   \n",
       "\n",
       "                                  eye_center0_3d_z  gaze_normal0_x  \\\n",
       "gaze_timestamp                                                       \n",
       "1970-01-01 00:01:28.150000+00:00        -20.027057       -0.127847   \n",
       "1970-01-01 00:01:28.160000+00:00        -20.301762       -0.244505   \n",
       "1970-01-01 00:01:28.170000+00:00        -20.325156       -0.022525   \n",
       "1970-01-01 00:01:28.180000+00:00        -20.153195       -0.166638   \n",
       "1970-01-01 00:01:28.190000+00:00        -20.652484       -0.118421   \n",
       "1970-01-01 00:01:28.200000+00:00        -20.954195       -0.157902   \n",
       "1970-01-01 00:01:28.210000+00:00        -20.933248       -0.146237   \n",
       "1970-01-01 00:01:28.220000+00:00        -20.902658       -0.084801   \n",
       "1970-01-01 00:01:28.230000+00:00        -20.905859       -0.166249   \n",
       "1970-01-01 00:01:28.240000+00:00        -20.756235       -0.144264   \n",
       "1970-01-01 00:01:28.250000+00:00        -20.779722       -0.099678   \n",
       "1970-01-01 00:01:28.260000+00:00        -20.820135       -0.145078   \n",
       "1970-01-01 00:01:28.270000+00:00        -20.787465       -0.146731   \n",
       "1970-01-01 00:01:28.280000+00:00        -20.779560       -0.150297   \n",
       "1970-01-01 00:01:28.290000+00:00        -20.842460       -0.093084   \n",
       "1970-01-01 00:01:28.300000+00:00        -20.750294       -0.128417   \n",
       "1970-01-01 00:01:28.310000+00:00        -20.804868       -0.135633   \n",
       "1970-01-01 00:01:28.320000+00:00        -20.829220       -0.134965   \n",
       "1970-01-01 00:01:28.330000+00:00        -20.827878       -0.145121   \n",
       "1970-01-01 00:01:28.340000+00:00        -20.842538       -0.147904   \n",
       "\n",
       "                                  gaze_normal0_y  gaze_normal0_z  \\\n",
       "gaze_timestamp                                                     \n",
       "1970-01-01 00:01:28.150000+00:00        0.067605        0.889367   \n",
       "1970-01-01 00:01:28.160000+00:00        0.090579        0.951078   \n",
       "1970-01-01 00:01:28.170000+00:00        0.007327        0.966231   \n",
       "1970-01-01 00:01:28.180000+00:00       -0.027207        0.973686   \n",
       "1970-01-01 00:01:28.190000+00:00        0.126559        0.969294   \n",
       "1970-01-01 00:01:28.200000+00:00        0.074265        0.957535   \n",
       "1970-01-01 00:01:28.210000+00:00        0.051453        0.963780   \n",
       "1970-01-01 00:01:28.220000+00:00        0.065100        0.975999   \n",
       "1970-01-01 00:01:28.230000+00:00        0.057002        0.930546   \n",
       "1970-01-01 00:01:28.240000+00:00        0.043767        0.950410   \n",
       "1970-01-01 00:01:28.250000+00:00        0.045776        0.949888   \n",
       "1970-01-01 00:01:28.260000+00:00        0.057476        0.925963   \n",
       "1970-01-01 00:01:28.270000+00:00        0.050133        0.954728   \n",
       "1970-01-01 00:01:28.280000+00:00        0.058772        0.955741   \n",
       "1970-01-01 00:01:28.290000+00:00        0.052902        0.943567   \n",
       "1970-01-01 00:01:28.300000+00:00        0.013018        0.980309   \n",
       "1970-01-01 00:01:28.310000+00:00        0.043154        0.945174   \n",
       "1970-01-01 00:01:28.320000+00:00        0.041200        0.949101   \n",
       "1970-01-01 00:01:28.330000+00:00        0.033099        0.923413   \n",
       "1970-01-01 00:01:28.340000+00:00       -0.011806        0.928220   \n",
       "\n",
       "                                  eye_center1_3d_x  eye_center1_3d_y  \\\n",
       "gaze_timestamp                                                         \n",
       "1970-01-01 00:01:28.150000+00:00        -39.709336         14.549297   \n",
       "1970-01-01 00:01:28.160000+00:00        -35.448202         14.565285   \n",
       "1970-01-01 00:01:28.170000+00:00        -35.357652         14.696238   \n",
       "1970-01-01 00:01:28.180000+00:00        -37.086310         14.788350   \n",
       "1970-01-01 00:01:28.190000+00:00        -36.983088         14.811906   \n",
       "1970-01-01 00:01:28.200000+00:00        -36.891102         14.793806   \n",
       "1970-01-01 00:01:28.210000+00:00        -37.100070         14.775316   \n",
       "1970-01-01 00:01:28.220000+00:00        -37.135465         14.774882   \n",
       "1970-01-01 00:01:28.230000+00:00        -37.274171         14.768857   \n",
       "1970-01-01 00:01:28.240000+00:00        -37.760146         14.754257   \n",
       "1970-01-01 00:01:28.250000+00:00        -37.704338         14.754874   \n",
       "1970-01-01 00:01:28.260000+00:00        -37.279303         14.776168   \n",
       "1970-01-01 00:01:28.270000+00:00        -37.168200         14.782509   \n",
       "1970-01-01 00:01:28.280000+00:00        -37.168377         14.779644   \n",
       "1970-01-01 00:01:28.290000+00:00        -37.168463         14.778240   \n",
       "1970-01-01 00:01:28.300000+00:00        -37.168463         14.778240   \n",
       "1970-01-01 00:01:28.310000+00:00        -37.168463         14.778240   \n",
       "1970-01-01 00:01:28.320000+00:00        -37.168463         14.778240   \n",
       "1970-01-01 00:01:28.330000+00:00        -37.168463         14.778240   \n",
       "1970-01-01 00:01:28.340000+00:00        -37.081902         14.778114   \n",
       "\n",
       "                                  eye_center1_3d_z  gaze_normal1_x  \\\n",
       "gaze_timestamp                                                       \n",
       "1970-01-01 00:01:28.150000+00:00        -19.780972       -0.148169   \n",
       "1970-01-01 00:01:28.160000+00:00        -25.917069       -0.144661   \n",
       "1970-01-01 00:01:28.170000+00:00        -26.142450       -0.126900   \n",
       "1970-01-01 00:01:28.180000+00:00        -23.480002       -0.052744   \n",
       "1970-01-01 00:01:28.190000+00:00        -23.625989       -0.220017   \n",
       "1970-01-01 00:01:28.200000+00:00        -23.749654       -0.151808   \n",
       "1970-01-01 00:01:28.210000+00:00        -23.444882       -0.124904   \n",
       "1970-01-01 00:01:28.220000+00:00        -23.415255       -0.157212   \n",
       "1970-01-01 00:01:28.230000+00:00        -23.238987       -0.116777   \n",
       "1970-01-01 00:01:28.240000+00:00        -22.535525       -0.110134   \n",
       "1970-01-01 00:01:28.250000+00:00        -22.626959       -0.120907   \n",
       "1970-01-01 00:01:28.260000+00:00        -23.354749       -0.107375   \n",
       "1970-01-01 00:01:28.270000+00:00        -23.543019       -0.108207   \n",
       "1970-01-01 00:01:28.280000+00:00        -23.535104       -0.118526   \n",
       "1970-01-01 00:01:28.290000+00:00        -23.531224       -0.142864   \n",
       "1970-01-01 00:01:28.300000+00:00        -23.531224       -0.090173   \n",
       "1970-01-01 00:01:28.310000+00:00        -23.531224       -0.120012   \n",
       "1970-01-01 00:01:28.320000+00:00        -23.531224       -0.112555   \n",
       "1970-01-01 00:01:28.330000+00:00        -23.531224       -0.101355   \n",
       "1970-01-01 00:01:28.340000+00:00        -23.633386       -0.056927   \n",
       "\n",
       "                                  gaze_normal1_y  gaze_normal1_z  \n",
       "gaze_timestamp                                                    \n",
       "1970-01-01 00:01:28.150000+00:00        0.097099        0.982526  \n",
       "1970-01-01 00:01:28.160000+00:00       -0.042391        0.978452  \n",
       "1970-01-01 00:01:28.170000+00:00        0.244343        0.946971  \n",
       "1970-01-01 00:01:28.180000+00:00        0.080061        0.991507  \n",
       "1970-01-01 00:01:28.190000+00:00        0.090418        0.967101  \n",
       "1970-01-01 00:01:28.200000+00:00        0.053767        0.984200  \n",
       "1970-01-01 00:01:28.210000+00:00        0.055827        0.987059  \n",
       "1970-01-01 00:01:28.220000+00:00        0.108161        0.975239  \n",
       "1970-01-01 00:01:28.230000+00:00        0.027554        0.987826  \n",
       "1970-01-01 00:01:28.240000+00:00        0.055378        0.986496  \n",
       "1970-01-01 00:01:28.250000+00:00        0.106926        0.979176  \n",
       "1970-01-01 00:01:28.260000+00:00        0.052359        0.990495  \n",
       "1970-01-01 00:01:28.270000+00:00        0.048913        0.986929  \n",
       "1970-01-01 00:01:28.280000+00:00        0.056326        0.988779  \n",
       "1970-01-01 00:01:28.290000+00:00        0.105255        0.981360  \n",
       "1970-01-01 00:01:28.300000+00:00        0.077162        0.990872  \n",
       "1970-01-01 00:01:28.310000+00:00        0.060891        0.987876  \n",
       "1970-01-01 00:01:28.320000+00:00        0.075101        0.990206  \n",
       "1970-01-01 00:01:28.330000+00:00        0.053868        0.990909  \n",
       "1970-01-01 00:01:28.340000+00:00        0.074000        0.990144  "
      ]
     },
     "execution_count": 147,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# T5 用pandas库\n",
    "import pandas as pd\n",
    "df = pd.read_csv('gaze.csv')\n",
    "df['gaze_timestamp'] = pd.to_datetime(df['gaze_timestamp'].values,unit = \"ms\",utc=True)\n",
    "# df.index = pd.to_datetime(df.gaze_timestamp.values)\n",
    "df.resample(\"0.01S\",on = \"gaze_timestamp\").mean().head(20)\n",
    "\n",
    "\n",
    "\n",
    "# # 用时间复杂度log(n)，需要很长时间跑\n",
    "# import csv\n",
    "# from bisect import bisect_left\n",
    "\n",
    "# row_data = []\n",
    "# i = 0\n",
    "\n",
    "# with open('gaze.csv','r') as csvfile:\n",
    "#     csv_reader = csv.reader(csvfile)  \n",
    "#     for row in csv_reader:            \n",
    "#         row_data.append(row[0])                              \n",
    "\n",
    "# del(row_data[0])\n",
    "# data = list(set(row_data))\n",
    "# data = [round(float(i),4) for i in data]\n",
    "# target_list = [data[0]]\n",
    "\n",
    "\n",
    "# def takeClosest(myList, myNumber):\n",
    "#     if (myNumber > myList[-1] or myNumber < myList[0]):\n",
    "#         return False\n",
    "#     pos = bisect_left(myList, myNumber)\n",
    "#     if pos == 0:\n",
    "#             return myList[0]\n",
    "#     if pos == len(myList):\n",
    "#             return myList[-1]\n",
    "#     before = myList[pos - 1]\n",
    "#     after = myList[pos]\n",
    "#     if after - myNumber < myNumber - before:\n",
    "#         return after\n",
    "#     else:\n",
    "#         return before\n",
    "    \n",
    "# while len(target_list) < 20:\n",
    "#         former = target_list[-1]\n",
    "#         later = takeClosest(data, former)\n",
    "#         targer_list.append(later)\n",
    "\n",
    "# print(target_list)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0d9d3fec",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
